package comp.wxapi.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import comp.wxapi.service.APIService;
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
import me.chanjar.weixin.common.session.StandardSessionManager;
import me.chanjar.weixin.common.session.WxSessionManager;
import weixin.popular.api.API;

@Configuration
public class WxapiServiceConfig {

	private static Logger logger = LoggerFactory.getLogger(WxapiServiceConfig.class);
	
	public WxapiServiceConfig() {}
	
	@Autowired
	public void setApiService(APIService apiService) {
		logger.info("set API Service");
		API.setApiHandler(apiService);
	}
	
	@Bean
	public WxMessageDuplicateChecker wxMessageDuplicateChecker() {
		
		return new WxMessageInMemoryDuplicateChecker();
	}
	
	@Bean
	public WxSessionManager wxSessionManager() {
		
		return new StandardSessionManager();
	}
}
